<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <div style="height:47px;"></div>

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <!-- <el-button @click="closeDrawer(2)" type="primary">保 存</el-button> -->
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import {getDetail,postSave} from '@/api/omSale/OrderManagement/PickAddress/index.js'
import {phoneAndSolidify} from '@/utils/validate.js'
export default {
  data(){
    this.saveData=null;
    return{
      formList:this.createdFrom(),
    }
  },
  props:['rowData'],
  mixins:[dictionary],
  created(){
    this.getDetail(this.rowData)
  },
  components:{
  },
  methods:{
    createdFrom(){
      return [
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          placeholder: '请选择',
          disabled:true,
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          },
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
        },
        {
          type: 'INPUT',
          label: '联系人',
          fieldName: 'linkMan',
          placeholder: '请输入',
          disabled:true,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
        },
        {
          type: 'SELECT',
          label: '地址性质',
          fieldName: 'addressProperty',
          placeholder: '请选择',
          disabled:true,
          itemList:this.createDictList('6035'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
        },
        {
          type: 'INPUT',
          label: '联系电话',
          fieldName: 'linkPhone',
          placeholder: '请输入',
          disabled:true,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
        },
        {
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          placeholder: '请选择',
          disabled:true,
          itemList:this.createRegionsList(),
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
        },
        {
          type: 'SELECT',
          label: '城市',
          fieldName: 'cityId',
          placeholder: '请选择',
          disabled:true,
          itemList:[],
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
        },
        {
          type: 'SELECT',
          label: '县区',
          fieldName: 'districtId',
          placeholder: '请选择',
          disabled:true,
          itemList:[],
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
        },
        {
          type: 'SELECT',
          label: '状态',
          fieldName: 'status',
          placeholder: '请选择',
          disabled:true,
          itemList:this.createDictList('1003'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
        },
        {
          type: 'MULTIPLE_SELECT',
          label: '地址类型',
          fieldName: 'addressTypeList',
          placeholder: '请选择',
          disabled:true,
          itemList:this.createDictList('6008'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
        },
        {
          type: 'INPUT',
          label: '详细地址',
          fieldName: 'address',
          placeholder: '请输入',
          disabled:true,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          selfCols:2
        },
        {
          type: 'INPUT',
          label: '结算目的地',
          fieldName: 'accountAddress',
          placeholder: '请输入',
          disabled:true,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'remark',
          placeholder: '请输入',
          disabled:true,
          selfCols:3,
        },

      ]
    },
     async getDetail(data){
      let res=await getDetail({addressId:data.addressId})
      for (let i in res.data) {
      this.formList.map(x => {
          if (i == x.fieldName) {
            x.initialValue = res.data[i];
          }
        });
      };
      this.dealerCode=data.dealerCode;
      this.formList.find(x=>x.fieldName=='cityId').itemList=this.createcityList(data.provinceId)
      this.formList.find(x=>x.fieldName=='districtId').itemList=this.district(data.cityId)
    },
    seacherFun(){
      this.issearch=true;
    },
    changeHandle(val){
      this.saveData=val;
    },
    async closeDrawer(type){
      if(type==1){
        this.$emit('close')
      }
    }
  }
}
</script>
